USE [OctoNetApps]
GO

/****** Object:  Table [classified].[ClassifiedAds]    Script Date: 05/25/2011 06:49:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [classified].[ClassifiedAds](
	[AdID] [bigint] NOT NULL,
	[ResourceID] [bigint] NOT NULL,
	[CategoryID] [bigint] NOT NULL,
	[PostTime] [smalldatetime] NOT NULL,
	[ExpiryTime] [smalldatetime] NOT NULL,
	[Searching] [bit] NOT NULL,
	[Title] [nvarchar](200) NOT NULL,
	[AdText] [nvarchar](max) NOT NULL,
	[TextFormat] [tinyint] NOT NULL,
	[Location] [geography] NULL,
	[PriceType] [tinyint] NOT NULL,
	[Price] [decimal](10, 2) NULL,
	[ContactPhone] [varchar](25) NULL,
	[ContactEmail] [varchar](50) NULL,
	[ContactUrl] [nvarchar](512) NULL,
	[UserID] [bigint] NULL,
	[UserComputerID] [bigint] NOT NULL,
	[UserIP] [varbinary](16) NOT NULL,
	[Status] [tinyint] NOT NULL,
	[Description] [varchar](300) NULL,
 CONSTRAINT [PK_ClassifedAds] PRIMARY KEY CLUSTERED 
(
	[AdID] ASC,
	[ResourceID] ASC,
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The ad expiration time.' , @level0type=N'SCHEMA',@level0name=N'classified', @level1type=N'TABLE',@level1name=N'ClassifiedAds', @level2type=N'COLUMN',@level2name=N'ExpiryTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'True if the type of the ad is ''need'', false if ''offer''.' , @level0type=N'SCHEMA',@level0name=N'classified', @level1type=N'TABLE',@level1name=N'ClassifiedAds', @level2type=N'COLUMN',@level2name=N'Searching'
GO

ALTER TABLE [classified].[ClassifiedAds]  WITH CHECK ADD  CONSTRAINT [FK_ClassifedAds_ClassifiedCategories] FOREIGN KEY([CategoryID])
REFERENCES [classified].[ClassifiedCategories] ([CategoryID])
GO

ALTER TABLE [classified].[ClassifiedAds] CHECK CONSTRAINT [FK_ClassifedAds_ClassifiedCategories]
GO

ALTER TABLE [classified].[ClassifiedAds]  WITH CHECK ADD  CONSTRAINT [FK_ClassifedAds_ClassifiedResources] FOREIGN KEY([ResourceID])
REFERENCES [classified].[ClassifiedResources] ([ResourceID])
GO

ALTER TABLE [classified].[ClassifiedAds] CHECK CONSTRAINT [FK_ClassifedAds_ClassifiedResources]
GO

ALTER TABLE [classified].[ClassifiedAds] ADD  CONSTRAINT [DF_ClassifedAds_Time]  DEFAULT (getutcdate()) FOR [PostTime]
GO

ALTER TABLE [classified].[ClassifiedAds] ADD  CONSTRAINT [DF_ClassifedAds_TextFormat]  DEFAULT ((0)) FOR [TextFormat]
GO


